package com.example.server.config;

import com.example.server.security.context.SecurityContextHolder;
import com.example.server.security.context.SessionBaesdSecurityContextHolder;
import com.example.server.security.context.TokenBasedSecurityContextHolder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;

public class SecurityContextHolderConfig {
    @Value("${yeb.security.context}")
    private String contextType;

    @Bean
    public SecurityContextHolder securityContextHolder(){
        if ("session".equals(contextType)) {
            return new SessionBaesdSecurityContextHolder();
        }else if ("token".equals(contextType)){
            return new TokenBasedSecurityContextHolder();
        }else{
            return new SessionBaesdSecurityContextHolder();
        }
    }
}
